<?php
/**
 * @copyright ©2020 浙江禾匠信息科技
 * @link: http://www.zjhejiang.com
 * Created by PhpStorm.
 * User: Andy - Wangjie
 * Date: 2020/4/30
 * Time: 17:21
 */

namespace app\plugins\flash_sale\controllers\api;

use app\core\response\ApiCode;
use Yii;

class ApiController extends \app\controllers\api\ApiController
{
    public function beforeAction($action)
    {
        //权限判断
        $permission = Yii::$app->branch->childPermission(Yii::$app->mall->user->adminInfo);
        if (!in_array('flash_sale', $permission)) {
            Yii::$app->response->data = ['code' => ApiCode::CODE_ERROR, 'msg' => '无限时抢购权限'];
            return false;
        }

        return parent::beforeAction($action); // TODO: Change the autogenerated stub
    }
}
